Socket
Socket
Sign inDemoInstall

linebreak

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linebreak

An implementation of the Unicode Line Breaking Algorithm (UAX #14)


Version published
Weekly downloads
764K
decreased by-4.36%
Maintainers
1
Weekly downloads
 
Created

What is linebreak?

The linebreak npm package is used for determining line break opportunities in text according to the Unicode Line Breaking Algorithm (UAX #14). It helps in handling text wrapping and formatting by identifying where lines can be broken in a way that maintains readability and adheres to typographic conventions.

What are linebreak's main functionalities?

Basic Line Breaking

This feature allows you to break a string into lines according to the Unicode Line Breaking Algorithm. The code sample demonstrates how to use the linebreak package to iterate through break points in a string and print each line.

const linebreak = require('linebreak');
const str = 'This is a sample text that needs line breaking.';
const breaker = linebreak(str);
let last = 0;
let bk;
while (!(bk = breaker.next()).done) {
  console.log(str.slice(last, bk.value.position));
  last = bk.value.position;
}

Custom Line Breaking

This feature allows you to customize the line breaking behavior by passing options. The code sample shows how to use a 'strict' line break mode to control the breaking points more precisely.

const linebreak = require('linebreak');
const str = 'Custom line breaking example.';
const breaker = linebreak(str, { lineBreak: 'strict' });
let last = 0;
let bk;
while (!(bk = breaker.next()).done) {
  console.log(str.slice(last, bk.value.position));
  last = bk.value.position;
}

Other packages similar to linebreak

Keywords

FAQs

Package last updated on 20 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc